using UnityEngine;
using UnityEngine.EventSystems;

namespace MaterialUI
{
	[AddComponentMenu("MaterialUI/Dropdown Trigger", 100)]
	public class DropdownTrigger : MonoBehaviour, IPointerClickHandler, ISubmitHandler, IEventSystemHandler
	{
		[SerializeField]
		private MaterialDropdown m_Dropdown;

		[SerializeField]
		private int m_Index;

		public MaterialDropdown dropdown
		{
			get
			{
				return m_Dropdown;
			}
			set
			{
				m_Dropdown = value;
			}
		}

		public int index
		{
			get
			{
				return m_Index;
			}
			set
			{
				m_Index = value;
			}
		}

		public void OnPointerClick(PointerEventData eventData)
		{
			if (dropdown != null)
			{
				dropdown.Select(m_Index);
			}
		}

		public void OnSubmit(BaseEventData eventData)
		{
			if (dropdown != null)
			{
				dropdown.Select(m_Index, submitted: true);
			}
		}
	}
}
